<!-- 取药 -->
<template>
	<view class="" style="background-color: #fdf6ec;padding: 9px 12px;color: #f9ae3d;font-size: 14px;">
		请选择要取药的人信息！
	</view>
	<view style="padding: 30rpx;padding-top: 0;" v-if="recipeList.length != 0">
		<view class="item" v-for="(item, index) in recipeList" :key="index" @click="onNavMedicine(item)">
			<image src="/static/icon/icon_avatar.png" mode=""></image>
			<view class="item-content">
				<view class="">
					<view class="name">
						{{item.reportName}}
					</view>
					<view class="id">
						身份证号：{{item.carido}}****{{item.caridt}}
					</view>
				</view>
			</view>
		</view>
	</view>
	
	<empty v-else></empty>
</template>

<script setup>
	import {ref} from "vue";
	import {mohuList, selpepiList} from "@/api/index.js";
	import {onLoad} from "@dcloudio/uni-app";
	
	const recipeList = ref([]);
	
	onLoad(() => {
		mohuList({
			durgname:'',
			page:1,
			limit:999
		}).then(res => {
			console.log("res" ,res)
			recipeList.value = res.data;
		})
	})
	
	function onNavMedicine(item) {
		// uni.setStorageSync('recipeItem', item)
		// uni.navigateTo({
		// 	url:'/view/recipe/medicineList/index'
		// })
		
		// return;
		
		selpepiList({perid:item.reportId,page:1,limit:999}).then(res => {
			console.log("res", res)
			if (res.data.length != 0) {
				uni.setStorageSync('recipeItem', item)
				uni.navigateTo({
					url:'/view/recipe/medicineList/index'
				})
			} else {
				uni.showToast({
					title: '没有药品可取，请先联系门诊医生开药！',
					icon:'none'
				})
			}
			
		})
		
		
		
		
	}
</script>

<style lang="scss">
	page {
		background-color: #F5F6FA !important;
	}
	.add {
		
		border-radius: 50rpx;
		/* 主要色/主要色 */
		background: #0256FF;
		
		position: fixed;
		bottom: 30rpx;
		left: 30rpx;
		right: 30rpx;
		height: 90rpx;
		line-height: 90rpx;
		
		text-align: center;
		
		
		font-family: Source Han Sans;
		font-size: 36rpx;
		/* 纯白 */
		color: #FFFFFF;
	}
	.item {
		display: flex;
		align-items: center;
		justify-content: flex-start;
		background-color: #FFF;
		margin-top: 20rpx;
		border-radius: 20rpx;
		padding: 28rpx;
		
		&:active {
			background-color: rgba(0,0,0,.1);
		}

		&:last-child {
			border-bottom: none;
		}
		image {
			width: 98rpx;
			height: 98rpx;
		}
		.item-content {
			margin-left: 18rpx;
			
			display: flex;
			flex-direction: row;
			justify-content: space-between;
			align-items: center;
			flex: 1;
			
			.name {
				font-family: '思源黑体';
				font-size: 28rpx;
				font-weight: normal;
				line-height: normal;
				letter-spacing: normal;
				/* 正文色/正文色 */
				color: #1A1A1A;
			}
			.id {
				font-family: '思源黑体';
				font-size: 26rpx;
				font-weight: normal;
				line-height: normal;
				letter-spacing: normal;
				/* 描边色/描边色辅助 */
				color: #AAAAAA;
				
				margin-top: 10rpx;
			}
			
			.modify {
				border: 1rpx solid #0256FF;
				padding: 5rpx 30rpx;
				font-size: 24rpx;
				border-radius: 50rpx;
				color: #0256FF;
				
				&:active {
					border: 1rpx solid #029aff;
					color: #029aff;
				}
			}
			.delete {
				border: 1rpx solid #ff4545;
				padding: 5rpx 30rpx;
				font-size: 24rpx;
				border-radius: 50rpx;
				color: #ff4545;
				margin-top: 10rpx;
				
				&:active {
					border: 1rpx solid #ff5a5a;
					color: #ff5a5a;
				}
			}
		}
		
		
	}
	
</style>